package com.niming;

public class EatableDemo {
    public static void main(String[] args) {
        // 在主方法中调用useEatable方法
        EatableImpl eatable = new EatableImpl();
        useEatable(eatable);

        // 匿名内部类
        useEatable(new Eatable() {
            @Override
            public void eat(int x, int y) {
                System.out.println("一天一苹果" + (x + y));
            }
        });

        // 匿名表达式
        useEatable((int x, int y) -> {
            System.out.println("一天一苹果" + (x + y));
        });
    }

    private static void useEatable(Eatable e) {
        e.eat(3, 5);
    }
}
